package cn.rongdao.jrkabao.widget;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;

/**
 * Created by Wang on 17/9/25.
 * 处理LinearLayout嵌套RecyclerView 不让RecyclerView消耗掉点击事件
 */

public class CusLinearLayout extends LinearLayout {
    boolean interceptor  = false;
    public CusLinearLayout(Context context) {
        super(context);
    }

    public CusLinearLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CusLinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if(interceptor){
            return true;
        }else {
            return super.onInterceptTouchEvent(ev);
        }
    }

    public void setInterceptor(boolean interceptor) {
        this.interceptor = interceptor;
    }
}
